/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nyrestaurantpaymentsystem;

import java.util.*;
import javax.swing.JTextArea;

/**
 *
 * @author Administrator
 */
public class Table {

    private int number;
    private String name;
    private Chair[] chairArray = new Chair[4];
    private boolean isEnabled = false;
    private int numberOfTables = 0;
    private int secondsSpent = 0;
    private int minutesSpent = 0;
    private boolean hasTimerTask = false;
    private MoneyTask moneytask;
    private JTextArea jTextArea;
    private Restaurant restaurant;
    
    public Table(Restaurant restInput, JTextArea jta)
    {
        restaurant = restInput;
        jTextArea = jta;
    }
    
    public JTextArea getJTextArea()
    {
        return jTextArea;
    }
            
    public void createAndAddMoneyTask(MoneyTimer mt)
    {   
        createMoneyTask();
        mt.addTimerTask(moneytask);
    }
    
    private void createMoneyTask()
    {
        moneytask = new MoneyTask(this);
    }
    
    public int getMoneySpent()
    {
    return secondsSpent;
    }
    
    public MoneyTask getMoneyTask()
    {
        return moneytask;
    }
    public void increaseMoney()
    {
        secondsSpent++;
        if(secondsSpent > 59)
        {
            minutesSpent += 1;
            secondsSpent -= 60;
        }
        restaurant.getGUI().updateTextField(jTextArea, String.valueOf(minutesSpent) + ":" + String.valueOf(secondsSpent));
        
    }
    
    public void setHasTimer(boolean b)
    {
        hasTimerTask = b;
    }
    
    public boolean hasTimer()
    {
            return hasTimerTask;
    }
}
